package com.learn.controller;

import com.learn.service.AuthCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: learn-parent
 * @description
 * @author: luffy
 * @create: 2020-09-16 10:56
 */
@RestController
@RequestMapping("/code")
public class AuthCodeController {

    @Autowired
    private AuthCodeService authCodeService;

    @GetMapping("/create/{email}")
    public boolean createCode(@PathVariable String email) {
        return authCodeService.createAuthCode(email);
    }



    @GetMapping("/validate/{email}/{code}")
    public Integer validateCode(@PathVariable String email,@PathVariable String code) {
        return authCodeService.validateAuthCode(email, code);
    }
}
